#!/usr/bin/env bash

if [ -z "$CI" ]; then
    echo "Will only continue on CI"
    exit
fi

# if [[ $CIRCLE_BRANCH != "master" ]]; then
#     echo "Will only continue for master builds"
#     exit
# fi

# build package and upload to private pypi index
echo "[distutils]" >> ~/.pypirc
echo "index-servers = pypi-private" >> ~/.pypirc
echo "[pypi-private]" >> ~/.pypirc
echo "repository=https://$PYPI_HOST" >> ~/.pypirc
echo "username=$PYPI_USERNAME" >> ~/.pypirc
echo "password=$PYPI_PASSWORD" >> ~/.pypirc
python3 -m pip install --user --upgrade twine
python3 setup.py sdist bdist_wheel
python3 -m twine upload -r pypi-private dist/*
